import java.util.Random;

/**
 * 加减法口算练习系统 - V0.1
 * 功能：生成50道100以内的加法或减法算式习题
 */
public class CalculationSystemV01 {
    public static void main(String[] args) {
        System.out.println("===== 加减法口算练习系统 - V0.1 =====");
        System.out.println("本次练习共50道题目，请认真完成！\n");
        
        generateExercises(50);
        
        System.out.println("\n===== 练习结束 =====");
    }
    
    /**
     * 生成指定数量的加减法习题
     * @param count 习题数量
     */
    public static void generateExercises(int count) {
        Random random = new Random();
        
        for (int i = 1; i <= count; i++) {
            // 随机决定是加法还是减法
            boolean isAddition = random.nextBoolean();
            int num1, num2, result;
            String operator;
            
            if (isAddition) {
                // 加法：确保结果不超过100
                num1 = random.nextInt(101); // 0-100
                num2 = random.nextInt(101 - num1); // 确保num1+num2 <= 100
                result = num1 + num2;
                operator = " + ";
            } else {
                // 减法：确保结果非负
                num1 = random.nextInt(101); // 0-100
                num2 = random.nextInt(num1 + 1); // 确保num2 <= num1
                result = num1 - num2;
                operator = " - ";
            }
            
            // 输出题目，不显示答案（练习模式）
            System.out.printf("%2d. %2d%s%2d = ____\n", i, num1, operator, num2);
            
            // 每10题空一行，增加可读性
            if (i % 10 == 0) {
                System.out.println();
            }
        }
    }
}